package pers.mihao.quickstream.common.model.result;

import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;

import java.util.List;

@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Data
public class PageResult<T> extends Result<List<T>> {

    private int pageNo;
    private int pageSize;
    private int total;

    public static <T> PageResult<T> returnSuccess(List<T> data, int totalCount) {
        PageResult<T> pageResult = new PageResult<>();
        pageResult.setTotal(totalCount);
        pageResult.setData(data);
        return pageResult;
    }


    public static <T> PageResult<T> success(List<T> data, int pageSize, int pageNo, int total) {
        PageResult<T> pageResult = new PageResult<>();
        pageResult.setSuccess(true);
        pageResult.setPageSize(pageSize);
        pageResult.setPageNo(pageNo);
        pageResult.setTotal(total);
        pageResult.setData(data);
        return pageResult;
    }
}
